package cc.vv.btpartyjob.partyservice.server

import android.text.TextUtils
import android.util.Log
import cc.vv.baselibrary.http.BaseHttpRequest
import cc.vv.baselibrary.util.UserInfoManageUtil
import cc.vv.btpartyjob.jnimodule.moudel.req.NewsRequestObj
import cc.vv.btpartyjob.jnimodule.moudel.resp.NewsResponseObj
import cc.vv.btpartyjob.partyservice.api.PartyServiceAPI
import cc.vv.btpartyjob.partyservice.module.bean.PartyServiceBean
import cc.vv.btpartyjob.partyservice.module.req.*
import cc.vv.btpartyjob.partyservice.module.resp.*
import cc.vv.lkbasecomponent.http.lib.setting.Settings
import cc.vv.lklibrary.http.base.okhttpfactory.plugins.httpplugin.MediaTypeWrap

/**
 * 假数据Server
 * Created by Chen.qi on 2018/10/24.
 */
object DataPartyServer {

    /**
     * 获取默认搜索数据
     */
    fun getDefaultHistoryStr(): ArrayList<String> {
        return arrayListOf("保洁", "月嫂", "电工", "司机", "服务员", "家政服务", "修理工", "钟点工", "切割焊工")
    }


    /** 获取党群新闻列表*/
    fun getPartyNewsList(page: Int, pageSize: Int, isShow: Boolean = false) {
        val request = NewsRequestObj()
        request.page = "$page"
        request.pageSize = "$pageSize"
        val path = PartyServiceAPI.partyGroupNews + "/" + "$page" + "/" + "$pageSize"
        BaseHttpRequest.postRequest(path, request, NewsResponseObj::class.java, isShow)
    }


    /** 获取岗位信息列表*/
    fun getStationList(streetId: String?, communityId: String?, gridId: String?, page: Int, pageSize: Int, isShow: Boolean = false) {
        val request = StationRequestObj()
        request.street = streetId
        request.community = communityId
        request.grid = gridId
        request.page = "$page"
        request.size = "$pageSize"
        val path = PartyServiceAPI.stationList + "/" + "$page" + "/" + "$pageSize"
        BaseHttpRequest.postRequest(path, request, StationResponseObj::class.java, isShow)
    }


    /** 岗位信息查询列表*/
    fun getStationSearchList(page: Int, pageSize: Int, search: String?, isShow: Boolean = false) {
        val request = StationRequestObj()
        request.postName = search
        request.page = "$page"
        request.size = "$pageSize"
        Log.e("lk_chen", "result==" + request.toString());
        val path = PartyServiceAPI.stationList + "/" + "$page" + "/" + "$pageSize"
        BaseHttpRequest.postRequest(path, request, StationResponseObj::class.java, isShow)
    }

    /** 获取求职信息列表*/
    fun getJobInfoList(streetId: String?, communityId: String?, gridId: String?, page: Int, pageSize: Int, isShow: Boolean = false) {
        val request = JobInfoRequestObj()
        request.street = streetId
        request.community = communityId
        request.grid = gridId
        request.page = "$page"
        request.size = "$pageSize"
        val path = PartyServiceAPI.jobInfoList + "/" + "$page" + "/" + "$pageSize"
        BaseHttpRequest.postRequest(path, request, JobInfoResponseObj::class.java, isShow)
    }

    /** 获取求职信息列表*/
    fun getJobInfoSearchList(page: Int, pageSize: Int, search: String?, isShow: Boolean = false) {
        val request = JobInfoRequestObj()
        request.page = "$page"
        request.size = "$pageSize"
        request.key = search
        val path = PartyServiceAPI.jobInfoList + "/" + "$page" + "/" + "$pageSize"
        BaseHttpRequest.postRequest(path, request, JobInfoResponseObj::class.java, isShow)
    }


    /** 获取志愿项目列表*/
    fun getVolunteerProjectList(projectName: String?, page: Int, pageSize: Int, isShow: Boolean = false) {
        val request = VolProRequestObj()
        request.projectName = projectName
        request.page = "$page"
        request.size = "$pageSize"
        val path = PartyServiceAPI.volunteerProjectList + "/" + "$page" + "/" + "$pageSize"
        BaseHttpRequest.postRequest(path, request, VolProResponseObj::class.java, isShow)
    }

    /** 获取资源清单列表*/
    fun getResourceList(streetId: String?, communityId: String?, gridId: String?, page: Int, pageSize: Int, isShow: Boolean = false) {
        val request = ResourceRequestObj()
        request.street = streetId
        request.community = communityId
        request.grid = gridId
        request.page = "$page"
        request.size = "$pageSize"
        val path = PartyServiceAPI.resourceList + "/" + "$page" + "/" + "$pageSize"
        BaseHttpRequest.postRequest(path, request, ResourceResponseObj::class.java, isShow)
    }

    /** 获取资源清单搜索列表*/
    fun getResourceSearchList(page: Int, pageSize: Int, title: String = "", startTime: Long = 0L, endTime: Long = 0L, isShow: Boolean = false) {
        val request = ResourceRequestObj()
        request.page = "$page"
        request.size = "$pageSize"
        if (!TextUtils.isEmpty(title)) {
            request.title = title
        }
        if (startTime > 1) {
            request.startTime = startTime
        }
        if (endTime > 1) {
            request.endTime = endTime
        }
        val path = PartyServiceAPI.resourceList + "/" + "$page" + "/" + "$pageSize"
        BaseHttpRequest.postRequest(path, request, ResourceResponseObj::class.java, isShow)
    }

    /** 获取需求清单搜索列表*/
    fun getDemandList(streetId: String?, communityId: String?, gridId: String?, page: Int, pageSize: Int, isShow: Boolean = false) {
        val request = DemandRequestObj()
        request.street = streetId
        request.community = communityId
        request.grid = gridId
        request.page = "$page"
        request.size = "$pageSize"
        val path = PartyServiceAPI.demandList + "/" + "$page" + "/" + "$pageSize"
        BaseHttpRequest.postRequest(path, request, DemandResponseObj::class.java, isShow)
    }

    /** 搜索需求清单搜索列表*/
    fun getDemandSearchList(page: Int, pageSize: Int, key: String?, startTime: String?, endTime: String?, isShow: Boolean = false) {
        val request = DemandRequestObj()
        request.page = "$page"
        request.size = "$pageSize"
        if (!TextUtils.isEmpty(key)) {
            request.key = key
        }
        if (!TextUtils.isEmpty(startTime)) {
            request.startTime = startTime
        }

        if (!TextUtils.isEmpty(endTime)) {
            request.endTime = endTime
        }
        val path = PartyServiceAPI.demandList + "/" + "$page" + "/" + "$pageSize"
        BaseHttpRequest.postRequest(path, request, DemandResponseObj::class.java, isShow)
    }


    /** 获取便民服务列表*/
    fun getSerPeopleList(streetId: String?, communityId: String?, gridId: String?, page: Int, pageSize: Int, isShow: Boolean = false) {
        val request = SerPeopleRequestObj()
        request.street = streetId
        request.community = communityId
        request.grid = gridId
        request.page = "$page"
        request.size = "$pageSize"
        val path = PartyServiceAPI.servicePeopleList + "/" + "$page" + "/" + "$pageSize"
        BaseHttpRequest.postRequest(path, request, SerPeopleResponseObj::class.java, isShow)
    }

    /** 获取便民服务搜索列表*/
    fun getSerPeopleSearchList(page: Int, pageSize: Int, key: String? = "", type: String? = "", isShow: Boolean = false) {
        val request = SerPeopleRequestObj()
        request.page = "$page"
        request.size = "$pageSize"
        if (!TextUtils.isEmpty(key)) {
            request.title = key
        }
        if (!TextUtils.isEmpty(type)) {
            request.type = type
        }
        val path = PartyServiceAPI.servicePeopleList + "/" + "$page" + "/" + "$pageSize"
        BaseHttpRequest.postRequest(path, request, SerPeopleResponseObj::class.java, isShow)
    }

    /** 便民服务类型列表*/
    fun getServiceTypeList(isShow: Boolean = false) {
        val request = ServiceTypeRequestObj()
        BaseHttpRequest.postRequest(PartyServiceAPI.servicePeopleTypeList, request, ServiceTypeResponseObj::class.java, isShow)
    }

    /** 获取留言板列表*/
    fun getMessageBoardList(page: Int, pageSize: Int, isShow: Boolean = false) {
        val request = MessageBoardRequestObj()
        request.page = "$page"
        request.size = "$pageSize"
        val path = PartyServiceAPI.messageBoardList + "/" + "$page" + "/" + "$pageSize"
        BaseHttpRequest.postRequest(path, request, MessageBoardResponseObj::class.java, isShow)
    }

    /**
     * 获取留言板详情信息
     */
    fun getMessageBoardDetail(id: String?, isShow: Boolean = false) {
        val request = MessageBoardDetailRequestObj()
        request.id = id
        val path = PartyServiceAPI.messageBoardDetailUrl + "/$id"
        BaseHttpRequest.getRequest(path, request, MessageBoardDetailResponseObj::class.java, isShow)
    }

    /**
     * 获取留言回复列表
     */
    fun getMessageBoardHuiFuList(id: String?, page: Int?, pageSize: Int?, isShow: Boolean = false) {
        val request = LiuYanHuiFuListRequestObj()
        request.id = id
        request.page = "$page"
        request.size = "$pageSize"
        val path = PartyServiceAPI.liuYanHuiFuList + "/" + "$page" + "/" + "$pageSize"
        BaseHttpRequest.postRequest(path, request, LiuYanHuifuListResponseObj::class.java, isShow)
    }

    /**
     * 保存回复信息
     */
    fun saveHuiFuInfo(id: String?, content: String?) {
        val request = SaveHuiFuRequestObj()
        request.messageBoardId = id
        request.content = content
        val userInfo = UserInfoManageUtil.getUserInfo()
        request.name = userInfo?.userName
        val path = PartyServiceAPI.saveHuiFuUrl
        BaseHttpRequest.postRequest(path, request, SaveHuiFuResponseObj::class.java, true,
                Settings(MediaTypeWrap.MEDIA_TYPE_RAW_JSON))
    }


    /** 获取微心愿列表*/
    fun getTinyWishList(streetId: String?, communityId: String?, gridId: String?, page: Int, pageSize: Int, isShow: Boolean = false) {
        val serBean = PartyServiceBean()
        serBean.street = streetId
        serBean.community = communityId
        serBean.grid = gridId
        val path = PartyServiceAPI.tinyWishList + "/" + "$page" + "/" + "$pageSize"
        BaseHttpRequest.postRequest(path, serBean, TinyWishResponseObj::class.java, isShow,
                Settings(MediaTypeWrap.MEDIA_TYPE_RAW_JSON))
    }


    /** 获取微捐赠列表*/
    fun getMicroDonationList(streetId: String?, communityId: String?, gridId: String?, page: Int, pageSize: Int, isShow: Boolean = false) {
        val serBean = PartyServiceBean()
        serBean.street = streetId
        serBean.community = communityId
        serBean.grid = gridId
        val path = PartyServiceAPI.microDonationList + "/" + "$page" + "/" + "$pageSize"
        BaseHttpRequest.postRequest(path, serBean, MicroDonationResponseObj::class.java, isShow,
                Settings(MediaTypeWrap.MEDIA_TYPE_RAW_JSON))
    }

    /** 发布留言*/
    fun subMessageHttp(name: String?, tel: String?, title: String?, content: String?, isShow: Boolean = false) {
        val subBean = SubMessageRequestObj()
        subBean.name = name
        subBean.mobile = tel
        subBean.title = title
        subBean.conetnt = content
        val path = PartyServiceAPI.subMessage
        BaseHttpRequest.postRequest(path, subBean, SubMessageResponseObj::class.java, isShow,
                Settings(MediaTypeWrap.MEDIA_TYPE_RAW_JSON))
    }

    /** 发布微心愿*/
    fun subTinyWishHttp(name: String?, tel: String?, address: String?, content: String?, startTime: Long?, endTime: Long?, isShow: Boolean = false) {
        val subBean = SubTinyWishRequestObj()
        subBean.name = name
        subBean.mobile = tel
        subBean.addr = address
        subBean.wishConetnt = content
        subBean.startTime = startTime
        subBean.endTime = endTime
        val path = PartyServiceAPI.subTinyWishHttp
        BaseHttpRequest.postRequest(path, subBean, SubTinyWishResponseObj::class.java, isShow,
                Settings(MediaTypeWrap.MEDIA_TYPE_RAW_JSON))
    }

    /** 发布微捐赠*/
    fun subMicDonationHttp(name: String?, tel: String?, address: String?, content: String?, startTime: Long?, endTime: Long?, isShow: Boolean = false) {
        val subBean = SubMicDonationRequestObj()
        subBean.microDonationName = name
        subBean.mobile = tel
        subBean.addr = address
        subBean.microDonationConetnt = content
        subBean.startTime = startTime
        subBean.endTime = endTime
        val path = PartyServiceAPI.subMicDonationHttp
        BaseHttpRequest.postRequest(path, subBean, SubMicDonationResponseObj::class.java, isShow,
                Settings(MediaTypeWrap.MEDIA_TYPE_RAW_JSON))
    }


    /** 微心愿详情*/
    fun tinyWishDetailHttp(id: String?, isShow: Boolean = false) {
        val detail = TinyWishDetailRequestObj()
        val path = PartyServiceAPI.tinyWishDetail + "/" + id
        BaseHttpRequest.getRequest(path, detail, TinyWishDetailResponseObj::class.java, isShow)
    }

    /** 微捐赠详情*/
    fun microDonationDetailHttp(id: String?, isShow: Boolean = false) {
        val detail = MicroDonationDetailRequestObj()
        val path = PartyServiceAPI.microDonationDetail + "/" + id
        BaseHttpRequest.getRequest(path, detail, MicroDonationDetailResponseObj::class.java, isShow)
    }


    /** 认领心愿*/
    fun claimWishHttp(id: String?, name: String?, mobile: String?, time: Long?, remark: String?, isShow: Boolean = false) {
        val subBean = ParamTinyWishRequestObj()
        subBean.clainMobile = mobile
        subBean.clainPerson = name
        subBean.remarks = remark
        subBean.endTime = time
        subBean.id = id
        subBean.claimState = 1
        val path = PartyServiceAPI.subTinyWishHttp
        BaseHttpRequest.postRequest(path, subBean, SubTinyWishResponseObj::class.java, isShow,
                Settings(MediaTypeWrap.MEDIA_TYPE_RAW_JSON))
    }


    /** 认领捐赠*/
    fun claimDonateHttp(id: String?, name: String?, mobile: String?, time: Long?, remark: String?, isShow: Boolean = false) {
        val subBean = ClaimDonateRequestObj()
        subBean.mobile = mobile
        subBean.person = name
        subBean.remarks = remark
        subBean.time = time
        subBean.microDonationId = id
        val path = PartyServiceAPI.microDonateSubmit
        BaseHttpRequest.postRequest(path, subBean, ClaimDonateResponseObj::class.java, isShow,
                Settings(MediaTypeWrap.MEDIA_TYPE_RAW_JSON))
    }

    /**
     * 我的心愿认领接口
     */
    fun getMainWishClaimList(page: Int, pageSize: Int, isShow: Boolean = false) {
        val wish = MineWishClaimRequestObj()
        wish.page = "$page"
        wish.size = "$pageSize"
        val path = PartyServiceAPI.mineWishClaimHttp + "/" + "$page" + "/" + "$pageSize"
        BaseHttpRequest.postRequest(path, wish, MainWishClaimResponseObj::class.java, isShow)
    }


    /**
     * 我的捐赠认领接口
     */
    fun getMainDonateClaimList(page: Int, pageSize: Int, isShow: Boolean = false) {
        val wish = MineWishClaimRequestObj()
        wish.page = "$page"
        wish.size = "$pageSize"
        val path = PartyServiceAPI.mineDonateClaimHttp + "/" + "$page" + "/" + "$pageSize"
        BaseHttpRequest.postRequest(path, wish, MineDonateClaimResponseObj::class.java, isShow)
    }


    /**获取志愿者列表*/
    fun getVolunteerList(streetId: String?, communityId: String?, gridId: String?, page: Int, pageSize: Int, name: String?, isShow: Boolean = false) {
        val volunteer = VolunteerRequestObj()
        volunteer.street = streetId
        volunteer.community = communityId
        volunteer.grid = gridId
        volunteer.name = name
        val path = PartyServiceAPI.volunteerList + "/" + "$page" + "/" + "$pageSize"
        BaseHttpRequest.postRequest(path, volunteer, VolunteerResponseObj::class.java, isShow
                , Settings(MediaTypeWrap.MEDIA_TYPE_RAW_JSON))
    }

    /**
     * 我的捐赠认领接口
     */
    fun getVolunteerInfo(id: String?, isShow: Boolean = false) {
        val request = VolinteerInfoRequestObj()
        request.id = id
        val path = PartyServiceAPI.volunteerPersonDetailUrl + "/" + "$id"
        BaseHttpRequest.getRequest(path, request, VolunteerInfoResponseObj::class.java, isShow)
    }


}